home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Portable Parts / Arrays / ArrayOf.cp < prev    next >
Encoding:
Text File  |  2000-06-23  |  892 b   |  43 lines

  1. // ArrayOf.cp
  2. #define ArrayOf_cp
  3.  
  4. #ifndef ArrayOf_h
  5. #include "ArrayOf.h"
  6. #endif
  7. #ifndef ArrayHeap_h
  8. #include "ArrayHeap.h"
  9. #endif
  10.  
  11. #include <string>
  12.  
  13. template < class Element >
  14. uint32 ArrayOf< Element >::operator<<( ConstArrayType r ) const
  15.   {
  16.     Assert( !this->Null() );
  17.     Assert( !r.Null() );
  18.     uint32 amount = this->BoundedLength( r.Length() );
  19.     
  20.     for ( uint32 i = 0; i < amount; i++ )
  21.         (*this)[i] = r[i];
  22.  
  23.     return amount;
  24.   }
  25.  
  26. template < class Element >
  27. uint32 ArrayOf< Element >::BitwiseCopy( ConstArrayType r ) const
  28.   {
  29.     Assert( !this->Null() );
  30.     Assert( !r.Null() );
  31.     uint32 amount = this->BoundedLength( r.Length() );
  32.     memcpy( this->Start(), r.Start(), amount );
  33.     //BlockMoveData( r.Start(), Start(), amount );
  34.     return amount;
  35.   }
  36.  
  37. template < class Element >
  38. void ArrayOf< Element >::SortBy( Comparison compare ) const
  39.   {
  40.     ArrayHeap<Element> heap( *this, compare );
  41.     heap.Sort();
  42.   }
  43.